﻿using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAL;

namespace BUS
{
    public class LoaiBUS
    {
        public static void INSERT(Loai D)
        {
            LoaiDAL DAL = new LoaiDAL();
            DAL.INSERT(D);
        }
        public static void UPDATE(Loai D)
        {
            LoaiDAL DAL = new LoaiDAL();
            DAL.UPDATE(D);
        }
        public static void DELETE(int iD)
        {
            LoaiDAL DAL = new LoaiDAL();
            DAL.DELETE(iD);
        }

        public static LoaiCollection GETALL()
        {
            LoaiDAL DAL = new LoaiDAL();


            int TotalRecords = 0;
            return DAL.GET("where 1=1", 0, 0,
                            LoaiColumn.MaLoai.ToString(),
                            "ASC", out TotalRecords);
        }

        public static LoaiCollection GET(string Where, int PageIndex, int PageSize, string OrderBy, string OrderDirection, out int TotalRecords)
        {
            LoaiDAL DAL = new LoaiDAL();
            return DAL.GET(Where, PageIndex, PageSize, OrderBy, OrderDirection, out TotalRecords);
        }
        public static Loai GetById(int iD)
        {
            int total = 0;
            LoaiDAL DAL = new LoaiDAL();
            LoaiCollection Collection = DAL.GET("where " + LoaiColumn.MaLoai.ToString() + "='" + iD + "'", 0, 0, LoaiColumn.MaLoai.ToString(), "ASC", out total);
            if (Collection.Count > 0)
                return Collection[0];
            return null;
        }
    }
}
